//
//  HWHWTradingPurchaseFailedController.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/9/28.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWHWTradingPurchaseFailedController.h"
#import "HWTradingPurchaseFailCell.h"
#import "HWClinchDealCell.h"

@interface HWHWTradingPurchaseFailedController ()<UITableViewDelegate,UITableViewDataSource>
@property(strong,nonatomic) UITableView *mainaTableVie;
@end

@implementation HWHWTradingPurchaseFailedController


-(UITableView *)mainaTableVie {
    
    if (_mainaTableVie == nil
        ) {
        
        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH) style:UITableViewStylePlain];
        _mainaTableVie.delegate = self;
        _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainaTableVie.backgroundColor = [UIColor whiteColor];
        
        
    }
    return   _mainaTableVie ;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addControlView];
    
    
}

//  添加视图控件
- (void)addControlView {
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"购买失败";
    [self.view addSubview:self.mainaTableVie];
    
    

}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    
    return  2;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    if (section == 0 ) {
        return  1;
        
        
    } else  {
        
          return  20;
    }
  //  return  20;
    
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    if (indexPath.section == 0) {
        
        static NSString *cellID = @"cellID1";
        HWTradingPurchaseFailCell  *cell =  [tableView dequeueReusableCellWithIdentifier:cellID];
        if (!cell) {
            cell =  [[NSBundle mainBundle]loadNibNamed:@"HWTradingPurchaseFailCell" owner:nil options:nil].lastObject;
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        return  cell;
    
        
        
    } else {
        
        
        static NSString *cellID = @"cellID";
        HWClinchDealCell *cell =  [tableView dequeueReusableCellWithIdentifier:cellID];
        if (!cell) {
            cell =  [[NSBundle mainBundle]loadNibNamed:@"HWClinchDealCell" owner:nil options:nil].lastObject;
        }
        cell.backgroundColor = [UIColor whiteColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        
        return  cell;
        
    }
    
  
    
}


#pragma  mark -------------- UITableViewDelegate


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    if (indexPath.section == 0) {
       return  48+22;
    }
    return   86;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return  0.01;
        
    }
    return  42;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    
    if (section == 0) {
        return  5+30+16;
    }
    return  0.001;
    
}



- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    
    if (section == 0 ) {
        
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.01)];
        return  view;
        
    } else {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36+6)];
        view.backgroundColor = RGB(232, 232, 242);
        
        UIView *baise = [[UIView alloc]initWithFrame:CGRectMake(0, 6, SCREEN_WIDTH, 36)];
        baise.backgroundColor = [UIColor whiteColor];
        [view addSubview:baise];
        
        UILabel *xianguanlanbel = [[UILabel alloc]initWithFrame:CGRectMake(13, 0, 200, 36)];
        xianguanlanbel.text = @"相关产品";
        xianguanlanbel.font = [UIFont systemFontOfSize:14];
        xianguanlanbel.textColor = RGB(51, 51, 51);
        [baise addSubview:xianguanlanbel];
    
        UIButton *butt = [UIButton createNormalButtonWithFrame:CGRectMake(kScreenW-38-20, 11, 38, 13) Image:@"ba_r" Title:@"更多" font:13 imageSize:CGSizeMake(7, 11)];
            [butt layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:4];
        //butt.backgroundColor = [UIColor yellowColor];
        [butt addTarget:self action:@selector(buttgenduTap) forControlEvents:UIControlEventTouchUpInside];
           // butt
        [baise addSubview:butt];
        return view;
    
        
    }
    
    
}

- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
    
    if (section == 1) {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.01)];
        view.backgroundColor = [UIColor whiteColor];
        return  view;
    }
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 5+30+16)];
    view.backgroundColor = [UIColor whiteColor];
    
    UIButton *butt  = [UIButton buttonWithType:UIButtonTypeCustom];
    butt.frame = CGRectMake(80, 5, SCREEN_WIDTH-160, 30);
    [butt setTitle:@"重新支付" forState:UIControlStateNormal];
    [butt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    butt.backgroundColor = RGB(38, 154, 255);
    butt.layer.cornerRadius = 15;
    butt.layer.masksToBounds = YES;
    [view addSubview:butt];
    return view;
    
}
#pragma mark ------- 点击更多按钮


- (void)buttgenduTap {
    
    [self.navigationController popToRootViewControllerAnimated:YES];
    
}


@end
